package vmcs.store;

import vmcs.common.VMCSException;

public class CashData extends Data {
	public CashData() throws VMCSException
	{
		super();
		dataImpl=implFactory.getCashImplementation();
		dataImpl.initialize();
	}
	@Override
	public StoreItem getItem(int id) {
		CashStoreItem cs;
		Coin cn = new Coin();
		String item, itemv;

		item = new String("Name" + id);
		itemv = dataImpl.getValue(item);
		cn.setName(itemv);

		item = new String("Weight" + id);
		itemv = dataImpl.getValue(item);
		cn.setWeight(Double.parseDouble(itemv));

		item = new String("Value" + id);
		itemv = dataImpl.getValue(item);
		cn.setValue(Integer.parseInt(itemv));
		item = new String("Quantity" + id);
		itemv = dataImpl.getValue(item);
		cs = new CashStoreItem(cn, Integer.parseInt(itemv));
		return cs;

	}

	@Override
	public void setItem(int it, StoreItem item) {
		// TODO Auto-generated method stub
		String  itn;
	    int  itemv;
	    String  its;
	    Coin  cn;
	    int idx = it + 1;
	    cn = (Coin) item.getContent();
	    itn = new String("Name" + idx);
	    dataImpl.setValue(itn, cn.getName());
	    itn = new String("Weight" + idx);
	    dataImpl.setValue(itn, String.valueOf(cn.getWeight()));
	    itn = new String("Value" + idx);
	    dataImpl.setValue(itn, String.valueOf(cn.getValue()));
	    itn = new String("Quantity" + idx);
	    dataImpl.setValue(itn, String.valueOf(item.getQuantity()));
	}
	
	

}
